package wang.Seacher.seven;

import java.time.LocalDateTime;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.geccocrawler.gecco.GeccoEngine;

import wang.Seacher.seven.dao.SevenInfoMapper;
import wang.Seacher.seven.entity.SevenInfo;
import wang.Seacher.util.DateTimeStyle;

public class StartSeven {

	// 使用"spring.xml"和"spring-mybatis.xml"这两个配置文件创建Spring上下文
	static ApplicationContext ac = new ClassPathXmlApplicationContext("spring-mybatis.xml");
//	static ApplicationContext ac = new ClassPathXmlApplicationContext("spring.xml");

	// 从Spring容器中根据bean的id取出我们要使用的funnyMapper对象
	static SevenInfoMapper sevenInfoMapper = (SevenInfoMapper) ac.getBean("sevenInfoMapper");

	// @Autowired
	// private static SevenInfoMapper sevenInfoMapper;

	public static void main(String[] args) {

		LocalDateTime startTime = DateTimeStyle.now();

		SevenInfo record = new SevenInfo();
		record.setName("name");
		record.setTopic("TOPIC");
		sevenInfoMapper.insert(record);

//		start();
		
		System.out.println("SEVEN---全部跑完  ----" + DateTimeStyle.duration(startTime));
	}

	private static void start() {
		GeccoEngine.create()
				// 工程的包路径
				.classpath("wang.Seacher.seven")
				// 开始抓取的页面地址
				// .start("http://www.99mm.me")
				.start("http://m.99mm.me/qingchun/2499.html")
//				.start("http://m.99mm.me/qingchun/2455.html")
				// .start("http://m.99mm.me/xinggan/2442.html")
				// .start("http://m.99mm.me/meitui/2442.html?url=3")
				// .start("http://m.99mm.me/qingchun/744.html")
				// .start("http://m.99mm.me/xinggan/745.html?url=30")
				// 开启几个爬虫线程
				.thread(100)
				// 单个爬虫每次抓取完一个请求后的间隔时间
				// .interval(100)
				// 循环抓取
				.loop(false)
				// 使用pc端userAgent
				.mobile(false)
				// 开始运行
				.run();
	}
}
